package com.qyhl.webtv.module_user.problem;

import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.gyf.immersionbar.ImmersionBar;
import com.qyhl.webtv.basiclib.base.BaseActivity;
import com.qyhl.webtv.basiclib.base.BaseIViewPresenter;
import com.qyhl.webtv.commonlib.constant.ARouterPathConstant;
import com.qyhl.webtv.module_user.R;
import com.qyhl.webtv.module_user.R2;
import com.weavey.loading.lib.LoadingLayout;

import butterknife.BindView;

/**
 * 常见问题
 */
@Route(path = ARouterPathConstant.COMMON_PROBLEM)
public class ProblemActivity extends BaseActivity {
    @BindView(R2.id.webview)
    WebView webView;
    @BindView(R2.id.load_mask)
    LoadingLayout load_mask;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


    }
    @Override
    protected int getContentView() {
        return R.layout.user_activity_problem;
    }

    @Override
    protected void setImmersionBar(ImmersionBar mImmersionBar) {
        setDefaultImmerBar();
    }

    @Override
    protected BaseIViewPresenter initBaseIViewPresenter() {
        return null;
    }

    @Override
    protected void init() {
        initView();
    }

    @Override
    protected void setListener() {

    }


    private void initView() {
        load_mask.setStatus(LoadingLayout.Loading);
        findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setDefaultTextEncodingName("utf-8");
        settings.setDomStorageEnabled(true);
        //是否阻塞加载网络图片  协议http or https
        settings.setBlockNetworkImage(false);
        settings.setUseWideViewPort(false);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setSupportZoom(false);
        settings.setBuiltInZoomControls(false);
        webView.loadUrl("http://wxshare.i2863.com/introduceIndex/indexIn.html");

        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                load_mask.setStatus(LoadingLayout.Success);
            }
        });
        removeWebViewJI(webView);
    }
}
